<template>
  <div>
    <f-form ref='form' :action='api.bhi' :form-key='this.formItem.inoviceId' :handlerName='handlerName' :file-ids='fileIds'>
      <div>
        <f-form-item label='开票金额' :required='true' data-type='number' disabled name='invoiceAmount' :value.sync='formItem.invoiceAmount' />
        <f-form-item label='发票号码' name='invoiceNo' :value.sync='formItem.invoiceNo' />
        <f-form-item label='开票日期' type='date' name='invoiceDate' :value='formItem.invoiceDate' />
        <f-form-item label='发票项目' name='title' :value='formItem.title' />
        <f-form-item label='签约日期' type='date' name='contractDate' :value.sync='formItem.contractDate' />
        <f-form-item label='完成销售额' name='saleAmount' data-type='number' :value.sync='formItem.saleAmount' />
        <f-form-item label='结算周期(起)' type='date' name='settleBeginDate' :value.sync='formItem.settleBeginDate' />
        <f-form-item label='结算周期(止)' type='date' name='settleEndDate' :value.sync='formItem.settleEndDate' />
        <f-form-item label='备注' name='remark' :value='formItem.remark' />
        <f-form-item label='附件' type='upload' name='paymentImage' :value='formItem.paymentImage' :file-max='3' :busId='this.formItem.paymentId' busType='BusPayment' :realRemove='true' @uploadSuccess='uploadSuccess' />
      </div>
    </f-form>
  </div>
</template>
<script>

import api from "../../../../js/api"

export default {
  name: "FapiaoForm",
  components: {},
  data() {
    let me = this
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {},
      loaded: false,
      handlerName: "hyInvoiceNoSavePaymentHandler",
      selectIds: "",
      fileIds: null,
      settleInvoiceId: null,
      invoiceAmount: 0,
      formItem: this.getFormItem()
    }
  },
  created() {
  },
  computed: {},
  methods: {
    getFormItem() {
      return {
        inoviceId: "",
        amountDate: "",
        invoiceNo: "",
        amount: 0,
        settleAmount: 0,
        invoiceDate: "",
        remark: ""
      }
    },
    setData(data) {
      if (data.inoviceId) {
        this.$refs.form.resetFields()
        this.http.get(this, {
          url: this.api.bhi.get,
          params: {
            inoviceId: data.inoviceId
          },
          success: (me, data) => {
            this.$nextTick(() => {
              this.formItem = data
              this.loaded = true
            })
          }
        })
      }
    },
    /**
     * 文件上传回调
     */
    uploadSuccess(fileUrl, files, fileIds, removeIds) {
      this.fileIds = fileIds
      this.removeIds.push(...removeIds)
    },
    handleSubmit() {
      this.$refs["form"].submit({
        invoiceUnitId: this.formItem.invoiceUnitId
      }, this.handleSuccess)
    },
    handleSuccess() {
      this.$emit("closeDrawer", false)
    }
  }
}
</script>
